package com.itc.dispatch.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itc.common.core.domain.R;
import com.itc.common.core.validate.Add;
import com.itc.common.core.validate.Delete;
import com.itc.common.core.validate.Update;
import com.itc.dispatch.domain.FlightDevice;
import com.itc.dispatch.domain.SysAlarmType;
import com.itc.dispatch.domain.dto.FlightDevicePageDto;
import com.itc.dispatch.domain.dto.SysAlarmTypePageDto;
import com.itc.dispatch.service.FlightDeviceService;
import com.itc.dispatch.service.SysAlarmTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("/flight/device")
@Api(value = "flightDevice", tags = "机位、登机口、摄像头关系映射管理模块")
public class FlightDeviceController {

    @Autowired
    private FlightDeviceService flightDeviceService;

    /**
     * 获取机位、登机口、摄像头关系映射数据
     */
    @PostMapping("/getList")
    @ApiOperation(value = "获取机位、登机口、摄像头关系映射数据")
    public R<List<FlightDevice>> getList(@RequestBody FlightDevice flightDevice){
       return flightDeviceService.getList(flightDevice);
    }

    /**
     * 机位、登机口、摄像头关系映射数据分页获取
     */
    @PostMapping("/getPage")
    @ApiOperation(value = "机位、登机口、摄像头关系映射数据分页获取")
    public R<Page<FlightDevice>>  getPage(@RequestBody FlightDevicePageDto pageDto){
        Page page = new Page();
        page.setCurrent(pageDto.getCurrent());
        page.setSize(pageDto.getSize());
        page.setSearchCount(true);
        return flightDeviceService.getPage(page,pageDto);
    }

    /**
     * 机位、登机口、摄像头关系映射数据更新
     */
    @PostMapping("/update")
    @ApiOperation(value = "机位、登机口、摄像头关系映射数据更新")
    public R update(@RequestBody @Validated(Update.class) FlightDevice flightDevice){
        return flightDeviceService.updateOne(flightDevice);
    }

    /**
     * 机位、登机口、摄像头关系映射数据删除
     */
    @PostMapping("/delete")
    @ApiOperation(value = "机位、登机口、摄像头关系映射数据删除")
    public R delete(@RequestBody @Validated(Delete.class) FlightDevice flightDevice){
        return flightDeviceService.delete(flightDevice);
    }

    /**
     * 机位、登机口、摄像头关系映射数据新增
     */
    @PostMapping("/add")
    @ApiOperation(value = "机位、登机口、摄像头关系映射数据新增")
    public R add(@RequestBody @Validated(Add.class) FlightDevice flightDevice){
        return flightDeviceService.add(flightDevice);
    }

    /**
     * 获取摄像头播放消信息
     */
    @PostMapping("/get/video")
    @ApiOperation(value = "获取摄像头播放消信息")
    public Page<FlightDevice> getFlightVideoPage(@RequestBody FlightDevicePageDto pageDto){
        Page page = new Page();
        page.setCurrent(pageDto.getCurrent());
        page.setSize(pageDto.getSize());
        page.setSearchCount(true);
        return flightDeviceService.getFlightVideoPage(page,pageDto);
    }
}
